#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <math.h> 
#include <ctype.h> 
#include <time.h> 
#include <assert.h>


void input(int arr[])
{
	for (int i = 0; i < 10; i++)
	{
		scanf("%d", &arr[i]);
	}
}

void check(int arr[])
{
	int signmax;
	int max = arr[0];
	int signmin;
	int min = arr[0];

	for (int i = 1; i < 10; i++)
	{
		if (max < arr[i])
		{
			max = arr[i];
			signmax = i;
		}
	}

	for (int i = 1; i < 10; i++)
	{
		if (min > arr[i])
		{
			min = arr[i];
			signmin = i;
		}
	}

	int temp = arr[signmax];
	arr[signmax] = arr[9];
	arr[9] = temp;

	temp = signmin;
	arr[signmin] = arr[0];
	arr[0] = temp;

}

void output(int arr[])
{
	for (int i = 0; i < 10; i++)
	{
		printf("%d ", &arr[i]);
	}
}

int main()
{
	int arr[10];
	input(arr);
	check(arr);
	output(arr);
	return 0;
}